<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>管理印章</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    <script src="/asset/layui/layui.js"></script>
    <link rel="Shortcut Icon" href="cachet.ico">
</head>
<body >
<div class="x-body">
		<div class="layui-form-item">
		    <div class="layui-inline">
		      <label class="layui-form-label">设备名称</label>
		      <div class="layui-input-inline layui-form-mid layui-word-aux">
		      	${devices.alias}
		      </div>
		    </div>
		    <div class="layui-inline">
		      <label class="layui-form-label">设备编号</label>
		      <div class="layui-input-inline layui-form-mid layui-word-aux">
		      	${devices.devicesCode}
		      </div>
		    </div>
		    <div class="layui-inline">
		      <label class="layui-form-label">状态</label>
		      <div class="layui-input-inline layui-form-mid layui-word-aux">
		      	${devices.devicesStatus}
		      </div>
		    </div>
		</div>
		
		<div class="layui-form-item">
		    <div class="layui-inline">
		      <label class="layui-form-label">开通时间</label>
		      <div class="layui-input-inline layui-form-mid layui-word-aux">
		      	<#if devices.bindingTime??>
		      	${devices.bindingTime?string('yyyy-MM-dd')}
		      	</#if>
		      	
		      </div>
		    </div>
		    <div class="layui-inline">
		      <label class="layui-form-label">失效时间</label>
		      <div class="layui-input-inline layui-form-mid layui-word-aux">
		      	<#if devices.expireDate??>
		      	${devices.expireDate?string('yyyy-MM-dd')}
		      	</#if>
		      </div>
		    </div>
		</div>

   
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">使用记录</li>
        </ul>
        <div class="layui-tab-content" >
            
            <div class="layui-tab-item layui-show">
                <table class="layui-table mytable" lay-even="" lay-skin="nob">
                    <thead>
                    <tr>
                        <th>使用时间</th>
                        <th>使用类型</th>
                        <th>使用地点</th>
                        <th>使用人</th>
                        <th>凭证记录</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <#list pm.datas as item>
                    <tr>
                        <td>${item.usedTime?string('yyyy-MM-dd HH:mm:ss')}</td>
                        <td>${item.applyType}</td>
                        <td>地区</td>
                        <td>${item.person.name}</td>
                        <td>
                        		<#if item.certUploadStatus=='WAIT_UPLOAD'>
                        			<a href="javascript:;" class="demoMore" lay-data="{devicesId: ${item.devicesId},devicesUsedId:${item.devicesUsedId}}">上传</a>
                        		</#if>
                        		<#if item.certUploadStatus=='UPLOAD'>
                        			<a href="javascript:;">查看</a>
                        		</#if>
                        </td>
                        <td>${item.usedStatus}</td>
                        <td>禁用</td>
                    </tr>
                    </#list>
                    
                    </tbody>
                </table>
                <div class="my_newlayerpage">
                    <@p.page pm=pm></@p.page>
                </div>
            </div>
        </div>
    </div>



</div>



<script>
layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;
  
   upload.render({
    elem: '.demoMore'
    ,url: '/upload/fileupload.htm?module=cert'
    
    ,done: function(res, index, upload){
      var devicesId = this.devicesId;
      var devicesUsedId = this.devicesUsedId;
      console.log(res);
      if(res.code == 1){
      		
      		var field = {
      			devicesId:devicesId,
      			devicesUsedId:devicesUsedId
      		}
      		field['upfiles[0].upfileId'] = res.data.upfileId;
          	field['upfiles[0].fileUrl'] = res.data.filepath;
      		
      		$.ajax({
      			type:"POST", 
      			url:"/devices/upcert.htm",
      			data:field,
      			success:function(result) {
		      
		      		if(result.code=='1'){
		      			layer.msg("上传成功");
		      			location.reload();
		      		}else{
		      		 	layer.msg(result.msg);
		      		}
		      
		    	 	} 
		    }); 
      	
      
      }
      
    }
  })
  
});
</script>



</body>
</html>